package com.springboot.chongwu.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.chongwu.entity.Sheying;
import com.springboot.chongwu.entity.view.SheyingView;
import com.springboot.chongwu.entity.view.SysManagerView;
import com.springboot.chongwu.mapper.SheyingMapper;
import com.springboot.chongwu.qpage.QPage;
import com.springboot.chongwu.service.ISheyingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.chongwu.util.ResultView;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 摄影 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-09-25
 */
@Service
public class SheyingServiceImpl extends ServiceImpl<SheyingMapper, Sheying> implements ISheyingService {

    @Override
    public ResultView getPageList(QPage qPage, SheyingView obj) {
        IPage iPage = new Page(qPage.getOffset(), qPage.getLimit());
        List<SheyingView> mapList = this.baseMapper.getPageList(iPage,obj);
        return ResultView.ok(iPage.setRecords(mapList));
    }

    @Override
    public ResultView add(Sheying obj) {
        obj.setCtime(new Date());
        obj.setUtime(new Date());
        this.save(obj);
        return ResultView.ok();
    }

    @Override
    public ResultView del(String id) {
        this.removeById(id);
        return ResultView.ok();
    }

    @Override
    public ResultView up(Sheying obj) {
        obj.setUtime(new Date());
        this.updateById(obj);
        return ResultView.ok();
    }

    @Override
    public List<SheyingView> getSelectList() {
        return baseMapper.getSelectList();
    }


}
